﻿/**
 * ...
 * @author 
 */
 
package racingGame.ui 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	import racingGame.events.ScreenEvent;
	
	
	public class Help extends MovieClip implements IStackableScreen
	{
		/**** Private Variables ****/
		
		private var _view 		:MovieClip;
		private var _car_btn	:MovieClip;
		private var _track_btn	:MovieClip;
		private var _enabled	:Boolean;
		
		
		
		/**** Public Methods ****/
		
		/**
		 * Constructor.
		 */
		public function Help() 
		{
			super();
			_view = new WindowAsset();
			addChild(_view);
			
			_view.x = 300;
			_view.y = 200;
			_view.title_txt.text = "Help";
			
			_car_btn = _view.addChild(new ButtonAsset()) as MovieClip;
			_car_btn.y = 40;
			_car_btn.buttonMode = true;
			_car_btn.mouseChildren = false;
			_car_btn.label_txt.text = "Car Test";
			
			_track_btn = _view.addChild(new ButtonAsset()) as MovieClip;
			_track_btn.y = 75;
			_track_btn.buttonMode = true;
			_track_btn.mouseChildren = false;
			_track_btn.label_txt.text = "Track Test";
			
		}
		
		
		/**
		 * Retrieves the enables status.
		 */
		public function get isEnabled() :Boolean
		{
			return _enabled;
		}
		
		
		/**
		 * Enable this screen.
		 */
		public function enable() :void
		{
			_enabled = true;
			_car_btn.addEventListener(MouseEvent.CLICK, onCarClick);
			_track_btn.addEventListener(MouseEvent.CLICK, onTrackClick);
			this.visible = _enabled;
		}
		
		
		/**
		 * Disable this screen.
		 */
		public function disable() :void
		{
			_enabled = false;
			_car_btn.removeEventListener(MouseEvent.CLICK, onCarClick);
			_track_btn.removeEventListener(MouseEvent.CLICK, onTrackClick);
			this.visible = _enabled;
		}
		
		
		/**** Callback Methods ****/
		
		/**
		 * Handle the click on the Car Button. Switch to the Test Car Screen.
		 * 
		 * @param	e	The click event.
		 */
		private function onCarClick(e :MouseEvent):void 
		{
			RacingGameMain.testMode = RacingGameMain.CAR_TEST;
			dispatchEvent(new ScreenEvent(ScreenEvent.SCREEN_EXIT, InGame));
		}
		
		
		/**
		 * Handle the click on the Car Button. Switch to the Test Track Screen.
		 * 
		 * @param	e	The click event.
		 */
		private function onTrackClick(e :MouseEvent):void 
		{
			RacingGameMain.testMode = RacingGameMain.TRACK_TEST;
			dispatchEvent(new ScreenEvent(ScreenEvent.SCREEN_EXIT, InGame));
		}
		
	}

}